<template>
	<view class="confirm-content">
		<view class="order-box">
			<view class="course-box">
				<view class="course-img">
					<image src="../../static/index/course.png" mode=""></image>
				</view>
				<view class="course-detail">
					<view>科一科四技巧答案（图表学习
						法全套解析）</view>
					<view>￥39.90</view>
				</view>
			</view>
			<view class="price-box">
				<view>总价</view>
				<view>￥39.90</view>
			</view>
			<view class="concat-box">
				<view class="concat-title">联系方式（选填）</view>
				<view class="input-box">
					<u-input v-model="value" type="number" placeholder='输入手机号码' />
					<u-button :custom-style="customStyle" open-type='getPhoneNumber'
						@getphonenumber="decryptPhoneNumber">一键获取</u-button>
				</view>
			</view>
			<view class="pay-box">
				<view>请选择支付方式</view>
				<view class="check-box">
					<view class="select-item" v-for="(item,index) in payTypeList" :key="item.id">
						<view class="select-title">
							<view class="title-image">
								<image :src="item.payImage" mode=""></image>
							</view>
							<view>{{item.payName}}</view>
						</view>
						<view class="select-text" @click="selectPay(item)">
							<image src="../../static/index/selected.png" mode="" v-if="item.checked"></image>
							<image src="../../static/index/select.png" mode="" v-if="!item.checked"></image>
						</view>
					</view>
				</view>
			</view>
			<view class="pay-know">
				<view>购买须知</view>
				<image src="../../static/index/right.png" mode=""></image>
			</view>
		</view>
		<view class="sub-btn">
			<u-button type="primary" shape="circle" :custom-style="customStyle1" @click="pay">立即支付</u-button>
		</view>
		<u-popup v-model="paySuccess" mode="center" border-radius="20" width="600rpx" height="400rpx">
			<view class="popup-box">
				<view class="popup-title">
					<image src="../../static/index/selected.png" mode=""></image>
					<view>支付成功</view>
				</view>
				<view>
					课程已购买，赶快去学习起来
				</view>
				<view>
					<u-button type="primary" shape="circle" :custom-style="customStyle1" @click="paySuccess = false">知道了</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				paySuccess:false,
				customStyle: {
					border: 'none',
					color: '#2AC092',
					background: 'transparent'
				},
				customStyle1: {
					color: '#fff',
					background: '#2AC092'
				},
				payTypeList: [{
						id: 1,
						payName: '微信支付',
						payImage: '../../static/index/wechat.png',
						checked: true
					},
					{
						id: 2,
						payName: '支付宝支付',
						payImage: '../../static/index/zhifub.png',
						checked: false
					}
				]
			}
		},
		methods: {
			decryptPhoneNumber(e) {
				console.log(e);
			},
			selectPay(item) {
				this.payTypeList.forEach(ele => {
					ele.checked = false
				})

				item.checked = true
			},
			pay(){
				this.paySuccess = true
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .u-hairline-border::after {
		border: none !important;
	}

	.order-box {
		padding: 20rpx;

		.course-box {
			background-color: #fff;
			border-radius: 10rpx;
			padding: 20rpx;
			display: flex;

			.course-img {
				width: 240rpx;
				height: 160rpx;
				border-radius: 10rpx;
				margin-right: 20rpx;

				>image {
					border-radius: 10rpx;
					width: 100%;
					height: 100%;
				}
			}

			.course-detail {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				>view:nth-child(1) {
					font-size: 30rpx;
					line-height: 1.5;
				}

				>view:nth-child(2) {
					font-size: 36rpx;
					color: #FF6D6A;
				}
			}
		}

		.price-box {
			display: flex;
			justify-content: space-between;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			margin-top: 20rpx;
		}

		.concat-box {
			padding: 20rpx;
			background-color: #fff;
			margin-top: 20rpx;
			border-radius: 10rpx;
			font-size: 30rpx;

			.input-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;
			}
		}

		.pay-box {
			padding: 20rpx;
			background-color: #fff;
			margin-top: 20rpx;
			border-radius: 10rpx;
			font-size: 30rpx;

			.check-box {
				margin-top: 20rpx;

				.select-item {
					padding: 20rpx;
					display: flex;
					justify-content: space-between;

					.select-title {
						display: flex;
						align-items: center;

						.title-image {
							margin-right: 28rpx;
							width: 50rpx;
							height: 50rpx;

							>image {
								width: 100%;
								height: 100%;
							}
						}
					}

					.select-text {
						width: 36rpx;
						height: 36rpx;

						>image {
							width: 100%;
							height: 100%;
						}
					}

				}
			}
		}

		.pay-know {
			display: flex;
			justify-content: space-between;
			padding: 20rpx;
			background-color: #fff;
			margin-top: 20rpx;
			border-radius: 10rpx;

			>image {
				width: 30rpx;
				height: 30rpx;
			}
		}
	}

	.sub-btn {
		position: fixed;
		bottom: 10rpx;
		padding: 20rpx;
		width: 100%;
		background-color: #fff;
	}
	
	.popup-box{
		padding: 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		height: 100%;
		
		.popup-title{
			display: flex;
			flex-direction: column;
			align-items: center;
			>image{
				width: 72rpx;
				height: 72rpx;
				margin-bottom: 20rpx;
			}
			
			>view{
				color: #2AC092;
				font-size: 30rpx;
			}
		}
	}
</style>